<!DOCTYPE html>
<html>
<head>
    <title>内切圆和正方形</title>
    <style>
        canvas {
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <canvas id="myCanvas" width="400" height="400"></canvas>

    <script>
       // 圆心坐标
var centerX = 280;
var centerY = 320;

// 圆的半径
var radius = 200;

// 直线的两个点
var point1 = [184, 49];
var point2 = [354, 530];

// 计算直线的斜率
var m;
if (point2[0] - point1[0] !== 0) {
    m = (point2[1] - point1[1]) / (point2[0] - point1[0]);
} else {
    // 对于竖直的直线，斜率为无穷大
    m = Infinity;
}

// 计算直线的截距
var c = point1[1] - m * point1[0];

// 计算直线与圆的交点的 y 坐标
var y1 = centerY + Math.sqrt(radius * radius - (centerX - point1[0]) * (centerX - point1[0]));
var y2 = centerY - Math.sqrt(radius * radius - (centerX - point1[0]) * (centerX - point1[0]));

// 计算交点的角度
var theta1 = Math.atan2(y1 - centerY, point1[0] - centerX);
var theta2 = Math.atan2(y2 - centerY, point1[0] - centerX);

console.log("第一个交点的角度：" + (theta1 * 180 / Math.PI) + "°");
console.log("第二个交点的角度：" + (theta2 * 180 / Math.PI) + "°");

    </script>
</body>
</html>
